package com.example.lol.ui;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.lol.R;
import com.example.lol.ui.adapter.NewsAdapter;
import com.example.lol.ui.adapter.YundAdapter;
import com.example.lol.ui.bean.NewBean;
import java.util.ArrayList;
import java.util.List;

public class FourthHomeFragment extends Fragment {
    private String[] title = new String[]{"【天神裁决天使】4裁决4天神2宗师",
            "【重装拉夫】4重装3龙魂3战神",
            "【七法龙王】7法师3龙魂3森林",
            "【重装拉夫】4重装3龙魂3战神",
            "【天神裁决天使】4裁决4天神2宗师"
    };

    private String[] hot = new String[]{"英雄联盟官方","聒噪的山海君","小xixi","走进李少波","lsb情感故事"};
    private int[] cover = new int[]{R.drawable.zr_1,
            R.drawable.zr_2,
            R.drawable.zr_3,
            R.drawable.zr_2,
            R.drawable.zr_1};

    private int[] lol = new int[]{R.drawable.tou2,
            R.drawable.ic_sg,
            R.drawable.ic_gt,
            R.drawable.tou2,
            R.drawable.ic_xf};

    private List<NewBean> initData() {
        List<NewBean> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            list.add(new NewBean()
                    .setTitle(title[i % title.length])
                    .setHot(hot[i % title.length])
                    .setDrawable(cover[i % cover.length])
                    .setLol(lol[i % lol.length])

            );
        }
        return list;
    }
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home_3, container, false);
        RecyclerView textView = view.findViewById(R.id.tv_text);
        textView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
        YundAdapter yundAdapter=new YundAdapter();
        yundAdapter.setList(initData());
        textView.setAdapter(yundAdapter);
        return view;
    }
}